﻿#ifndef WIDGET_H
#define WIDGET_H

#include <QWidget>
#include <QObject>
#include <QTcpSocket>
#include <QHostAddress>
#include <QJsonDocument>
#include <QJsonParseError>
#include <QFile>
#include <QJsonObject>
#include <QDebug>
#include <QJsonArray>
#include <QStandardItemModel>
#include <QTime>
#include <QCheckBox>
#include <QVector>
#include <QVBoxLayout>
#include "login.h"
#include "filedownload.h"

#define DEFAULT_IP "192.168.157.134"
#define DEFAULT_PORT 8888

typedef struct _ST_FILE_ {
    QString file_name;
    QString file_path;
    int file_id;
    uint upload_time;
    int is_share;
}ST_FILE;


namespace Ui {
class Widget;
}

class Widget : public QWidget
{
    Q_OBJECT

public:
    explicit Widget(QWidget *parent = 0);
    void sendFileRequest();
    void parseFileList(QJsonObject root);
    ~Widget();


public slots:
    void slotRecv();
    void slotLoginButClic(QString username, QString password);
    void slotRefreshMyFile();
private:
    Ui::Widget *ui;
    QTcpSocket* client_socket;  //客户端套接字
    Login *login_widget;
    QString username;
    int user_id;
    QString icon;
    QVector <ST_FILE> my_file_list;
    QStandardItemModel *standItemModel;
    QVBoxLayout *layout_transfor;
};

#endif // WIDGET_H
